package ruralmanagementsystem.mapper;

import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;
import ruralmanagementsystem.dto.HouseholdDTO;
import ruralmanagementsystem.pojo.Household;
import ruralmanagementsystem.vo.HouseholdVO;

@Mapper
public interface HouseholdMapper {
    //根据户主电话返回村户信息
    @Select("select * from rural.household_tb where holder = #{phone}")
    Household getHouseholdByHolder(String phone);

    //新增村户信息
    @Insert("insert into rural.household_tb values (null, #{name}, #{holder}, #{members}, #{field}, " +
            "#{password})")
    void addHousehold(Household household);

    //分页查询村户信息
    Page<Household> paginationQuery(HouseholdDTO householdDTO);

    //根据id修改村户信息
    @Update("update rural.household_tb set name = #{name}, holder = #{holder}, members = #{members}, " +
            "field = #{field},  password = #{password} where id = #{id}")
    void updateHousehold(Household household);

    //根据id删除村户信息
    @Delete("delete from rural.household_tb where id = #{id}")
    void deleteHousehold(Integer id);
}
